using System;

namespace T0065
{
    public class Weapon
    {
        /// <summary>
        /// Weapon Base Class
        /// </summary>
        private string _name;//武器名称
        private int _magazineCapacity;//弹匣容量
        private int _ammoNumInMc;//当前弹匣中的弹药数量
        protected float _attackDis;//攻击范围
        protected float _fireRate;//射速
        private int _totalAmmoNum;//Maximum Ammo

        public int TotalAmmoNum
        {
            get => _totalAmmoNum;
            set => _totalAmmoNum = value;
        }

        public int MagazineCapacity
        {
            get => _magazineCapacity;
            set 
            {
                if(value>0)
                    _magazineCapacity = value;
                
            }
        }

        public int AmmoNumInMc
        {
            get => _ammoNumInMc;
            set => _ammoNumInMc = value;
        }

        //Fire
        public virtual void Fire()
        {
            //Console.WriteLine("Base Class Fire!");
            //decrease ammo while shooting
            if (_ammoNumInMc > 0)
            {
                _ammoNumInMc--;
                _totalAmmoNum--;
            }
                
            else Reload();
        }
        //Reload
        public void Reload()
        {
            //Console.WriteLine("Base Class Reloading!");
            if (_totalAmmoNum > _magazineCapacity)
            {
                Console.WriteLine("Reloading!");
                _ammoNumInMc = _totalAmmoNum;
            }
            
        }
        //Print Weapon's Status
        public virtual void PrintWeaponStatus()
        {
            Console.WriteLine("------{Weapon Status}------");
            Console.WriteLine("Weapon Name: {0} ",_name);
            Console.WriteLine("Ammo / Magazine: {0} / {1} ",_ammoNumInMc,_totalAmmoNum);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="magazineCapacity"></param>
        /// <param name="ammoNumInMc"></param>
        /// <param name="attackDis"></param>
        /// <param name="fireRate"></param>
        /// <param name="totalAmmoNum"></param>
        public Weapon(string name, int magazineCapacity, int ammoNumInMc, float attackDis, float fireRate, int totalAmmoNum)
        {
            _name = name;
            _magazineCapacity = magazineCapacity;
            _ammoNumInMc = ammoNumInMc;
            _attackDis = attackDis;
            _fireRate = fireRate;
            _totalAmmoNum = totalAmmoNum;
            
        }
    }
}